/*
** Copyright (C) 2009 Joshua Brent Marsh <joshua@icub3d.com>
**  
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**  
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**  
*/

/* $Id: rbbtree_funcs.h 36 2009-11-02 15:06:50Z joshua@icub3d.com $ */

#ifndef ICUB3D_RBBTREE_H
#define ICUB3D_RBBTREE_H 1

#include "btree.h"

#define RBBTREE_BLACK 0
#define RBBTREE_RED   1

/* Create a new node. */
struct btree_node * new_rbbtree_node (void *, int, 
				      struct btree_node *,
				      struct btree_node *);

/* Get the color of a node. Usefule in that some nodes may be NULL. */
int node_color (struct btree_node *);

/* These are going to be used to help with balancing and deleting. */
void rbbtree_insert_case1 (Btree *, struct btree_node *);
void rbbtree_insert_case2 (Btree *, struct btree_node *);
void rbbtree_insert_case3 (Btree *, struct btree_node *);
void rbbtree_insert_case4 (Btree *, struct btree_node *);
void rbbtree_insert_case5 (Btree *, struct btree_node *);

void rbbtree_remove_case1 (Btree *, struct btree_node *);
void rbbtree_remove_case2 (Btree *, struct btree_node *);
void rbbtree_remove_case3 (Btree *, struct btree_node *);
void rbbtree_remove_case4 (Btree *, struct btree_node *);
void rbbtree_remove_case5 (Btree *, struct btree_node *);
void rbbtree_remove_case6 (Btree *, struct btree_node *);

#endif /* ICUB3D_RBBTREE_H */
